package com.ruoyi.project.module.ossconfig.domain;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.framework.web.domain.BaseEntity;

import java.nio.charset.StandardCharsets;
import java.util.Date;

/**
 * 阿里云OSS资源表 oss_config
 * 
 * @author ruoyi
 * @date 2019-04-08
 */
public class OSSConfig extends BaseEntity
{
	private static final long serialVersionUID = 1L;
	
	/** 主键 */
	private Integer ossConfigId;
	/** 访问密钥 */
	private String accessKeyId;
	/** 秘密访问密钥 */
	private String secretAccessKey;
	/** 节点名称 */
	private String endpoint;
	/** 存储空间名称 */
	private String bucketName;
	/** OSS文件名称 */
	private String fileName;
	/** OSS内容类型 */
	private String ossContentType;
	/** 文件内容 */
	private byte[] fileContent;
	/** 添加时间 */
	private Date addtime;
	/** 更新时间 */
	private Date updateTime;

	private String description;

	private String fileContentStr;

	public void setOssConfigId(Integer ossConfigId) 
	{
		this.ossConfigId = ossConfigId;
	}

	public Integer getOssConfigId() 
	{
		return ossConfigId;
	}
	public void setAccessKeyId(String accessKeyId) 
	{
		this.accessKeyId = accessKeyId;
	}

	public String getAccessKeyId() 
	{
		return accessKeyId;
	}
	public void setSecretAccessKey(String secretAccessKey) 
	{
		this.secretAccessKey = secretAccessKey;
	}

	public String getSecretAccessKey() 
	{
		return secretAccessKey;
	}
	public void setEndpoint(String endpoint) 
	{
		this.endpoint = endpoint;
	}

	public String getEndpoint() 
	{
		return endpoint;
	}
	public void setBucketName(String bucketName) 
	{
		this.bucketName = bucketName;
	}

	public String getBucketName() 
	{
		return bucketName;
	}
	public void setFileName(String fileName) 
	{
		this.fileName = fileName;
	}

	public String getFileName() 
	{
		return fileName;
	}
	public void setOssContentType(String ossContentType) 
	{
		this.ossContentType = ossContentType;
	}

	public String getOssContentType() 
	{
		return ossContentType;
	}
	public void setAddtime(Date addtime)
	{
		this.addtime = addtime;
	}

	public Date getAddtime() 
	{
		return addtime;
	}
	@Override
	public void setUpdateTime(Date updateTime)
	{
		this.updateTime = updateTime;
	}

	@Override
	public Date getUpdateTime()
	{
		return updateTime;
	}

    @Override
	public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("ossConfigId", getOssConfigId())
            .append("accessKeyId", getAccessKeyId())
            .append("secretAccessKey", getSecretAccessKey())
            .append("endpoint", getEndpoint())
            .append("bucketName", getBucketName())
            .append("fileName", getFileName())
            .append("ossContentType", getOssContentType())
            .append("fileContent", getFileContent())
            .append("addtime", getAddtime())
            .append("updateTime", getUpdateTime())
            .toString();
    }

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public byte[] getFileContent() {
		return fileContent;
	}

	public void setFileContent(byte[] fileContent) {
		this.fileContent = fileContent;
	}

	public String getFileContentStr(){
		if(this.fileContent==null){
			return null;
		}

		return new String(this.fileContent,StandardCharsets.UTF_8);
	}

	public void setFileContentStr(String fileContentStr) {
		if(fileContentStr!=null){
			this.fileContent=fileContentStr.getBytes(StandardCharsets.UTF_8);
		}else {
			this.fileContent=null;
		}
	}
}
